package com.guigu.financial.service.impl;

import com.guigu.financial.mapper.DictMapper;
import com.guigu.financial.pojo.Dict;
import com.guigu.financial.service.DictService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class DIctServiceImpl implements DictService {
    @Autowired
    private DictMapper dictMapper;
    @Override
    public String getNameByParentDictCodeAndValue(String dictCode, Integer value) {
        Dict dict = dictMapper.selectByDictCode(dictCode);
        List<Dict> dicts = dictMapper.selectByParentId(dict.getId());
        for (Dict dict1 : dicts) {
            if (dict1.getValue().equals(value)){
                return dict1.getName();
            }
        }
        return null;
    }
}
